package a05threadmethod2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86131
 * Date: 2024-04-16
 * Time: 23:02
 */
public class ThreadDemo {
    public static void main(String[] args) {
/*        setPriority(int newPriority)    是指线程的优先级
        final int getPriority()         获取线程的优先级      */

        //创建线程要执行的参数对象
        MyRunnable mr = new MyRunnable();

        //创建线程对象
        Thread t1 = new Thread(mr, "飞机");
        Thread t2 = new Thread(mr, "坦克");

        //查看优先级  默认 5
//        System.out.println(t1.getPriority());
//        System.out.println(t2.getPriority());

        //获取当前执行对象线程(main)的优先级
        //System.out.println(Thread.currentThread().getPriority());

        t1.setPriority(1);
        t2.setPriority(10);   //优先级只是概率问题

        t1.start();
        t2.start();
    }
}
